// $Id: config.hpp 2 2009-09-02 08:47:42Z joseph2002 $
/*
 * Copyright 2008 Joseph Wu
 * Distributed under the Boost Software License, Version 1.0.
 * (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
 *
 * For more information, see http://xpcomplus.sourceforge.net
 */

#ifndef XPCOM_API_NSPR_CONFIG_HPP
#define XPCOM_API_NSPR_CONFIG_HPP

#include <xpcom/config.hpp>

// Platform specific definitions
// Win32
#if defined(XPCOM_PLATFORM_WIN32)
#  define _NSPR_IMPORT(__type) __declspec(dllimport) __type
#  define _NSPR_IMPORT_DATA(__type) __declspec(dllimport) __type
#  define _NSPR_CALLBACK

// BeOS
#elif defined(XPCOM_PLATFORM_BEOS)
#  define _NSPR_IMPORT(__type) extern __declspec(dllexport) __type
#  define _NSPR_IMPORT_DATA(__type) extern __declspec(dllexport) __type
#  define _NSPR_CALLBACK

// XXX Win16, this is not supported really
#elif defined(XPCOM_PLATFORM_WIN16)
#  if defined(_WINDLL)
#    define _NSPR_IMPORT(__type) extern __type _cdecl _export _loadds
#    define _NSPR_IMPORT_DATA(__type) extern __type _export
#    define _NSPR_CALLBACK __cdecl __loadds
#  else // this must be .EXE
#    define _NSPR_IMPORT(__type) extern __type _cdecl _export
#    define _NSPR_IMPORT_DATA(__type) extern __type _export
#    define _NSPR_CALLBACK __cdecl __loadds
#  endif // _WINDLL

// MacOS
#elif defined(XPCOM_PLATFORM_MACOS)
#  define _NSPR_IMPORT(__type) extern __declspec(export) __type
#  define _NSPR_IMPORT_DATA(__type) extern __declspec(export) __type
#  define _NSPR_CALLBACK

// XXX OS2, not available..
#elif defined(XPCOM_PLATFORM_OS2) && defined(__declspec)
#  define _NSPR_IMPORT(__type) extern  __declspec(dllimport) __type
#  define _NSPR_IMPORT_DATA(__type) extern __declspec(dllimport) __type
#  define _NSPR_CALLBACK

// XXX OS2/VACPP, not available..
#elif defined(XPCOM_PLATFORM_OS2_VACPP)
#  define _NSPR_IMPORT(__type) extern __type
#  define _NSPR_IMPORT_DATA(__type) extern __type
#  define _NSPR_CALLBACK _Optlink

// Unix
#else
#  ifdef XPCOM_HAS_VISIBILITY_ATTRIBUTE // GCC >= 3.3, defined in compiler.hpp
#    define _NSPR_VISIBILITY_DEFAULT __attribute__((visibility("default")))
#  else
#    define _NSPR_VISIBILITY_DEFAULT
#  endif

#  define _NSPR_IMPORT(__type) extern _NSPR_VISIBILITY_DEFAULT __type
#  define _NSPR_IMPORT_DATA(__type) extern _NSPR_VISIBILITY_DEFAULT __type
#  define _NSPR_CALLBACK

#endif // end of platform

// _NSPR_API/_NSPR_DATA_API
// NSPR library API function declarations.
#define _NSPR_API(__type) _NSPR_IMPORT(__type)
#define _NSPR_DATA_API(__type) _NSPR_IMPORT_DATA(__type)

// _NSPR_BEGIN_MACRO/_NSPR_END_MACRO
// Macro body brackets so that macros with compound statement definitions
// behave syntactically more like functions when called.
#define _NSPR_BEGIN_MACRO   do {
#define _NSPR_END_MACRO     } while (0)

// _NSPR_BEGIN_EXTERN_C/_NSPR_END_EXTERN_C
// Macro shorthands for conditional C++ extern block delimiters.
#ifdef __cplusplus
#  define _NSPR_BEGIN_EXTERN_C  extern "C" {
#  define _NSPR_END_EXTERN_C    }
#else
#  define _NSPR_BEGIN_EXTERN_C
#  define _NSPR_END_EXTERN_C
#endif

#endif // XPCOM_API_NSPR_CONFIG_HPP
